<?php if (! defined('BASEPATH') ) die("No direct script access allowed.");


	/**
	 * $APP_PATH/libraries/Theme.php
	 * 
	 * Provides static access to current theme information.
	 * 
	 * @author 	Mark Skilbeck, Mahcuz.com, 2009.
	 * @link   	http://mahcuz.com
	 * @package	PHP Project Tracker
	 */
	 
	 
	class Theme {
	 	
	 	/**
	 	 * @access 	public
	 	 * @var		string
	 	 */
		static $theme_name;
		
		/**
		 * @access 	public
		 * @var		string
		 */
	 	static $theme_alias;
	 	
 		/**
 		 * @access 	public
 		 * @var		string
 		 */
	 	static $theme_type;
 	
 		/**
 		 * @access 	public
 		 * @var		int
 		 */
	 	static $theme_id;
	 	
 		/**
 		 * CodeIgniter superclass access point.
 		 * 
 		 * @access	private
 		 * @var		obj
 		 */
	 	static $CI;
	 	
	 	/**
	 	 * Cousin, Theme_model, that provides access to database info
	 	 *
	 	 * @access	private
	 	 * @var		obj
	 	 */
 	 	static private $Theme_model;
 	 	
 	 	/**
 	 	 * Theme::Theme()
 	 	 * 
 	 	 * Constructor will exit if:
 	 	 *  - a. get_instance() function does not exist. Needed for access to codeigniter.
 	 	 *  - b. we cannot get the instance using get_instance().
 	 	 *  - c. the Theme_model is not loaded. Needed for access to database.
 	 	 */
	 	public function Theme() {}
	 	
	 	static public function init() {
	 		if (!function_exists('get_instance')) {
	 			exit;
	 		}
	 		self::$CI =& get_instance();
	 		
	 		if (!isset(self::$CI->theme_model)) {
	 			log_message('error', 'Theme_model is not loaded.');
	 		}
	 		self::$Theme_model = self::$CI->theme_model;
	 	}
	 	/**
	 	 * Theme::load_theme()
	 	 * 
	 	 * Loads the current theme for the given theme type.
	 	 * 
	 	 * @access	public
	 	 * @param	string
	 	 * @return  void
	 	 */
	 	static public function load_theme_type($theme_type) {
	 		
	 		$theme = self::$Theme_model->get_current_theme($theme_type);
	 		
	 		self::$theme_name  = $theme->theme_name;
	 		self::$theme_type  = $theme->theme_type;
	 		self::$theme_alias = $theme->theme_alias;
	 		self::$theme_id    = $theme->id;
	 	}
	 	
	}


?>